package com.android.rutaszalagarda;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import android.os.AsyncTask;
import android.util.Log;

public class Conexion extends AsyncTask<Connection,Void,Connection> {
	private static final String url = "jdbc:mysql://217.160.206.205:3306/zalaRutas_";
	private static final String user = "usuarioMovil";
	private static final String password = "rutasZalagarda";
    protected Connection doInBackground(Connection... con) {
    	ResultSet rs = null;
    	try {
    		String result = "";
    		Class.forName("com.mysql.jdbc.Driver");
    		con[0] = DriverManager.getConnection(url, user, password);
    		System.out.println("Success");
    		Statement st = con[0].createStatement();
    		rs = st.executeQuery("select * from prueba");
    		while(rs.next()) {
    			result += ("prueba" + rs.getString(1));
    		}
    		Log.v("resultado",result);
    	} catch (Exception e) {
    		Log.v("error",e.getMessage());
    		e.printStackTrace();
    	}
       return con[0];
    }

    protected void onPostExecute(ResultSet result) {
        Log.v("FTPTask","FTP connection complete");
        //resultado = result;
        //Where ftpClient is a instance variable in the main activity
    }
}
